package com.ruoyi.system.domain.wrapper.view;

import cn.hutool.core.bean.BeanUtil;
import com.eic.framework.core.domain.BaseEntityWrapperV;
import com.ruoyi.system.domain.dao.SysUser;
import com.ruoyi.system.domain.view.SysUserVo;

/**
 * 用户信息前端实体包装
 *
 * @author 尹国春
 * @date 2022-07-19
 */
public class SysUserWrapperV extends BaseEntityWrapperV<SysUser, SysUserVo> {

    private static SysUserWrapperV wrapperV=null;
    //示例代码
    //private static IDemoDeptService demoDeptService;
    private SysUserWrapperV(){
    }

    public static SysUserWrapperV build(){
        if(wrapperV==null){
            //示例代码
            //demoDeptService= SpringUtils.getBean(IDemoDeptService.class);
            //Assert.notNull(demoDeptService);
            wrapperV=new SysUserWrapperV();
        }
        return wrapperV;
    }

    @Override
    public SysUserVo entityVO(SysUser entity) {
        if(entity==null){
            return new SysUserVo();
        }
        SysUserVo vo = BeanUtil.copyProperties(entity,SysUserVo.class);
        //示例代码
        //vo.setDeptName(getFieldValue(demoDeptService,entity.getDeptId(),DemoDept::getDepartName));
        return vo;
    }

    /*示例代码
    @Override
    public List<SysUserVo> listVO(List<SysUser> list) {
        List<SysUserVo> voList=list.stream().map(user -> BeanUtil.copyProperties(user,SysUserVo.class)).collect(Collectors.toList());
        copyForeignKeyData(voList,SysUserVo::getDeptId,SysUserVo::setDeptName,demoDeptService,DemoDept::getDepartName);
        return voList;
    }
    */
}